Skip to content

Fix manual tool calling regression in v0.1.14#266

Open
harijay wants to merge 1 commit intoandrewyng:mainfrom
harijay:harijay/fix-manual-tool-calling-regression
Open

Fix manual tool calling regression in v0.1.14#266
harijay wants to merge 1 commit intoandrewyng:mainfrom
harijay:harijay/fix-manual-tool-calling-regression

Conversation

@harijay
Copy link

@harijay harijay commented Jan 21, 2026

Problem

Manual tool calling broke in v0.1.14. When passing tool schemas without max_turns, the LLM doesn't see the available tools and responds normally instead of making tool calls.

Root Cause

In client.py line 330, the code uses kwargs.pop("tools") which removes tools from kwargs. When max_turns is None (manual tool calling mode), execution reaches line 355 which calls the provider without tools in kwargs, causing the LLM to not see the tool schemas.

Reproduction

import aisuite as ai

# Manual tool schema
tools = [{
    "type": "function",
    "function": {
        "name": "get_time",
        "description": "Get current time",
        "parameters": {}
    }
}]

client = ai.Client()
response = client.chat.completions.create(
    model="openai:gpt-4o",
    messages=[{"role": "user", "content": "What time is it?"}],
    tools=tools,  # Tools schema is lost!
)

# Result: LLM doesn't see tools, responds normally
# Expected: LLM makes a tool_call

Solution

  1. Line 330: Changed from kwargs.pop("tools") to kwargs.get("tools") to preserve tools in kwargs
  2. Line 345: Added explicit kwargs.pop("tools") when using max_turns, since _tool_runner handles them separately
  3. Added tests: Comprehensive test coverage to prevent future regressions

Changes

  • aisuite/client.py: 3 lines changed
  • tests/client/test_manual_tool_calling.py: New test file

Impact

Manual tool calling (no max_turns): Now works correctly
Automatic tool execution (with max_turns): Continues to work as expected
No breaking changes to existing functionality

Testing

Added unit tests that verify:

  • Tools are passed to provider in manual mode
  • Tools are not duplicated in automatic mode
  • MCP config processing continues to work

All tests pass:

pytest tests/client/test_manual_tool_calling.py -v

Related

Co-Authored-By: Warp agent@warp.dev

When using manual tool calling (without max_turns parameter), tool schemas
were not being passed to the provider, causing LLMs to not see available tools.

## Problem
In v0.1.14, line 330 uses kwargs.pop("tools") which removes tools from kwargs.
When max_turns is None, execution reaches line 355 which calls the provider
without tools, breaking manual tool calling.

## Solution
- Changed line 330 from kwargs.pop() to kwargs.get() to preserve tools in kwargs
- Added explicit kwargs.pop("tools") at line 345 when using max_turns
- Added comprehensive tests to prevent future regressions

## Impact
- Manual tool calling now works correctly without max_turns
- Automatic tool execution with max_turns continues to work as expected
- No breaking changes to existing functionality

Fixes manual tool calling for users following the documented approach at:
https://github.com/andrewyng/aisuite#manual-tool-calling-no-max_turns

Co-Authored-By: Warp <agent@warp.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant